objWshell.Run "%COMSPEC% /C ren topoX.jpg topo_cliente.jpg", 0, TRUE ???

  • Thread starter Vilmar Brazão de Oliveira
  • Start date
V

Vilmar Brazão de Oliveira

Hi all,
I was using:
<% Set objWshell = Server.CreateObject("WScript.Shell")
objWshell.Run "%COMSPEC% /C ren topoX.jpg topo_cliente.jpg", 0, TRUE %>

BUT the comand COMSPEC disapeared of all my machines which we have
ms-windows 2000 installed!
So now no-one machine can continue run my routines which accessed ms-dos by
ASP

COULD anybody send me the comspec command by e-mail whith the subject:
Comspec to WScript.Shell
???

obs.:I got these samples in aspfaq.com »»
http://www.aspfaq.com/show.asp?id=2059
thanks,
--

Sem mais,

««««««««»»»»»»»»»»»»»»
Vlmar Brazão de Oliveira
Desenvolvimento Web
HI-TEC
 
R

Ray at

%compspec% isn't a command. It's an environment variable that represents
the path to your command interpreter executable, cmd.exe.

Right click My Computer
Click Properties
Advanced tab
Environment Variables

In the System Variables box, ComSpec should be the first one listed, on a
default W2K Server. If it is not there, add it.

Variable name: ComSpec
Variable value: C:\Winnt\System32\cmd.exe


Note that for that value, this is for a W2K Server installed on C with a
%systemroot% of C:\Winnt. If you have no environment variables at all, you
may want to inquire about this in microsoft.public.win2000.general or
..win2000.cmdprompt.admin.

Ray at work
 
A

Aaron Bertrand [MVP]

Too lazy to try, but can you use %sysdir% or %systemroot% in the definition
of another environment variable? I'm not sure if the variables are
initialized in order or en masse... but it's not like that value is going to
change in the existing environment anyway.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
 
R

Ray at

I do believe that you can, because the actual value of an environment
variable like %windir% is actually %systemroot%. But, since it's stored as
a REG_EXPAND_SZ, when you view the variable anywhere, the expanded value of
%systemroot% is what's displayed.

And %comspec% is actually %systemroot%\system32\cmd.exe. So, I guess I gave
false instructions about recreating that variable. Sorry Vilmar.

I guess if the var is stored as a REG_SZ, you'd have to type the literal
path.

Ray at work
 
V

Vilmar Brazão de Oliveira

Hi all,
I have tried:
objWshell.Run "%systemroot%\system32\cmd.exe /C ren topoX.jpg
topo_cliente.jpg", 0, TRUE\cmd.exe

objWshell.Run "c:\winnt\\system32\cmd.exe /C ren topoX.jpg
topo_cliente.jpg", 0, TRUE\cmd.exe

But nothing is running well!
If %COMSPEC% keeps away the path of command interpreter why my ASP routines
can not execute the WSH correctly??

Thanks untill here,
--

««««««««»»»»»»»»»»»»»»
Vlmar Brazão de Oliveira
Desenvolvimento Web
HI-TEC
 
R

Ray at

Did you read anything in my first post about checking your environment
variables?

Ray at work
 
V

Vilmar Brazão de Oliveira

Hi,
I read all the last posts. Again: thanks for them.
Here is all the system variable which my o.s. ms-windows 2000 produces:
C:\>set
ALLUSERSPROFILE=C:\Documents and Settings\All
APPDATA=C:\Documents and Settings\rute\Dados d
CommonProgramFiles=C:\Arquivos de programas\Ar
COMPUTERNAME=SUP14
ComSpec=C:\WINNT\system32\cmd.exe
HOMEDRIVE=N:
HOMEPATH=\
HOMESHARE=\\Webserver\d$
LOGONSERVER=\\SUP14
NUMBER_OF_PROCESSORS=1
OS=Windows_NT
Os2LibPath=C:\WINNT\system32\os2\dll;
Path=C:\Arquivos de programas\Borland\Delphi5\
WINNT\System32\Wbem
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 4 Step
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=0404
ProgramFiles=C:\Arquivos de programas
PROMPT=$P$G
SystemDrive=C:
SystemRoot=C:\WINNT
TEMP=C:\DOCUME~1\rute\CONFIG~1\Temp
TMP=C:\DOCUME~1\rute\CONFIG~1\Temp
USERDOMAIN=SUP14
USERNAME=rute
USERPROFILE=C:\Documents and Settings\rute
windir=C:\WINNT

So what shoud I do??
thanks all,
--

««««««««»»»»»»»»»»»»»»
Vlmar Brazão de Oliveira
Desenvolvimento Web
HI-TEC
 
R

Ray at

Alright, your variables are cool then. (This is from your ~server~, right,
not your workstation?) Now I can't remember how I determined or assumed
that it might be a system variable problem to begin with!

Are you able to log on to the server directly? If so, if you enter the same
command at the command prompt (cmd.exe), does it work? That command being:

ren topoX.jpg topo_cliente.jpg

One other thing that I just noticed is that you aren't specifying the PATH
to your file. I believe that cmd.exe will open in the user's home directory
(IUSR's) or if the user doesn't have a home directory specified, it'll be
the system32 directory. So, try:

ren C:\Path\To\Your\File\topoX.jpg topo_cliente.jpg

Ray at work
 
A

Aaron Bertrand [MVP]

But nothing is running well!
BUT the comand COMSPEC disapeared

What does "running well" mean? What does "disappeared" mean? Maybe you
could show the actual error message you are receiving. I am betting it's a
permissions issue... did you recently make any changes to IUSR on this
machine, or change anonymous to Windows auth or vice versa, or perhaps make
the site or application run in its own memory space? The user ASP is
running as needs elevated privileges in order to run a command like cmd.exe
....

(Also, please trim, trim, trim. We don't need to see your original post 20
times in the thread.)
 
V

Vilmar Brazão de Oliveira

HI people,
»»»NOW IS OK!!!
I really had forgot the PATH. See now the correct code that can runs even
without %COMSPEC% appear in my system variables of my ms-windows operating
system:
objWshell.Run "c:\winnt\system32\cmd.exe /C ren
d:\testes_apostilas\topoX.jpg topo_cliente.jpg", 0, TRUE

Thanks to everybody.
--

Sem mais,

««««««««»»»»»»»»»»»»»»
Vlmar Brazão de Oliveira
Desenvolvimento Web
HI-TEC
 
P

Phill. W

I /almost/ hate to do this, but ... yes; I'm in an ASP group, so ...

Vilmar,

Have you come across FileSystemObject?
For renaming files, it may work rather better that WShell...

<%
Dim oFSO
Set oFSO = CreateObject( "Scripting.FileSystemObject" )

Call oFSO.MoveFile( "<path>\topoX.jpg", "<path>\topo_cliente.jpg" )

%>

HTH,
Phill W.
 
V

Vilmar Brazão de Oliveira

thank by the new tip, but I still prefer WSH. it is better for us have all
control of o.s. shell!
best regards,
--

««««««««»»»»»»»»»»»»»»
Vlmar Brazão de Oliveira
Desenvolvimento Web
HI-TEC
 
A

Aaron Bertrand [MVP]

thank by the new tip, but I still prefer WSH. it is better for us have all
control of o.s. shell!

No, it's not, IMHO. Why does a web app need "all control of o.s. shell"?
 
R

Ray at

I'm often more in favor of executing shell commands when I can too, since it
often simplifies code and is a bit more efficient. <-- That is an assumption
I've made.

Ray at work
 
A

Aaron Bertrand [MVP]

often simplifies code

In the case of filesystemObject, I disagree. To each his own, I suppose.
and is a bit more efficient.

That's a rather bold assumption. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top