Login | |
|
 |
RE: comspec - 8/28/2007 12:50:17 AM
|
|
 |
|
| |
gdewrance
Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
|
Set WshShell = WScript.CreateObject("WScript.Shell") SysRoot = WshShell.ExpandEnvironmentStrings ("%SystemRoot%") is this SysRoot & "\System32\cmd.exe /k cd "& Chr(34) & "%1" &Chr(34),"REG_SZ" the same as %comspec% /k cd "& Chr(34) & "%1" &Chr(34),"REG_SZ"
|
|
| |
|
|
|
 |
RE: comspec - 8/28/2007 12:53:18 AM
|
|
 |
|
| |
dm_4ever
Posts: 2663
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
|
Should be the same Set WshShell = WScript.CreateObject("WScript.Shell") SysRoot = WshShell.ExpandEnvironmentStrings ("%SystemRoot%") WScript.Echo SysRoot & "\System32\cmd.exe /k cd "& Chr(34) & "%1" &Chr(34) WScript.Echo WshShell.ExpandEnvironmentStrings("%comspec%") & " /k cd " & Chr(34) & "%1" &Chr(34)
_____________________________
dm_4ever My philosophy: K.I.S.S - Keep It Simple Stupid Read Me: http://www.visualbasicscript.com/m_24727/tm.htm Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: comspec - 8/28/2007 12:56:07 AM
|
|
 |
|
| |
gdewrance
Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
|
thanks, I just remember reading once that it is a different command interpreter.
|
|
| |
|
|
|
 |
RE: comspec - 8/28/2007 7:11:14 AM
|
|
 |
|
| |
mcds99
Posts: 434
Score: 4
Joined: 2/28/2006
Status: online
|
It depends on your OS. Windows 3.x, Bob, 95, 98, ME, NT, 2000, XP are not the same when it comes to the command interpreter. compspec says use the local version of command interpreter making the script more portable. If you have a script with cmd.exe defined the it will not work on W98 or ME
_____________________________
Sam Keep it Simple Make it Fun KiSMiF
|
|
| |
|
|
|
 |
RE: comspec - 8/28/2007 5:02:54 PM
|
|
 |
|
| |
gdewrance
Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
|
mcds99 that makes sense, since they use command.com So if you open cmd.exe and type Set you will see comspec=c:\windows\system32\cmd.exe and if you use Set in command.com comspec=c:\windows\system32\command.com edit: CMD.EXE is a command line processor for 32bit Windows. Much like MS-DOS before it, it provides a character-mode only user interface into which you can type commands to run programs. CMD.EXE is a 32 bit program that is fully a part of Windows - in fact it's what gets run when you select Command Prompt on the Windows Accessories menu. COMMAND.COM, on the other hand, exists only for compatibility and 16bit programs. It exists solely for those programs which have not been updated since the days of MS-DOS. It's designed to run 16bit applications, and operates just like the old MS-DOS did. On the surface, they're very similar. Even though CMD.EXE was a complete re-write, it's based on the same concepts and similar syntax. But the differences become quickly apparent. Let's used your "CD" example from above. In CMD.EXE, you can change to the "Program files" directory by doing this: cd "\Program Files" Note the quotes around the directory name. Try doing that in COMMAND.COM and you'll get this: cd "\Program Files" Parameter format not correct - "\program The problem is COMMAND.COM doesn't know about long file names (filenames longer than 8.3) or filenames that have spaces in them, and it doesn't have a way to quote the name. So if you still need to, how do you CD to that directory in COMMAND.COM? Well, first you need to find out the alternate, 8.3 name of that directory ... its short name: So I take it if you run old Windows platforms you would need to stick to 8.3 naming convention Thanx
< Message edited by gdewrance -- 8/28/2007 5:38:01 PM >
|
|
| |
|
|
|
 |
RE: comspec - 8/30/2007 3:59:37 AM
|
|
 |
|
| |
mcds99
Posts: 434
Score: 4
Joined: 2/28/2006
Status: online
|
YES and NO. Do this. Create a file with a long file name i.e. myfilenameistolong.txt Open a command prompt and drill down to the directory where the file is located. do a DIR /X you will get the list of short and long file names. 8/30/2007 11:50 AM 0 MYFILE~1.TXT myfilenameistolong.txt You can use that file name to test your script with short names. The only problem is you will get MYFILE~2.TXT if there is a file with a similar name like myfilename.txt BTW If you want to create a file at the command prompt but don't want to open edit or not pad try "copy con". Example: "c:\>copy con myfilenameistolong.txt" type some text "this is what will be in the file " Press F6 for the end of file marker, and press enter to write the file. you will have your file 8-O
_____________________________
Sam Keep it Simple Make it Fun KiSMiF
|
|
| |
|
|
|
|
|