| 1. |
Solve : Need help with "Diskpart" and "Shutdown" command? |
|
Answer» Hi all, I have a question about VB script that I hope you guys can give me some help on. Here's the situation I ran into. What I have is a vbscript that calls and try to execute a cmd file.file Please show us the code that executes the cmd file. You may have to use paths on the diskpart and shutdown commands. Prior to the cmd file execute, trying expanding the %path% variable to see if the system32 directory is included. In the batch file also check the expansion of the %path% variable. Something may have gotten messed up in the switch between the vbs and cmd environments. Here's the simple code that I am running. Code on VBScript: set shell = CREATEOBJECT("WScript.shell") shell.Run "run_restart.cmd" ================================ Code on the command file: diskpart shutdown pause It's really nothing flashy. But those two commands is totally throwing off the program. I have checked out %path% on the regular prompt and running it on the command file. They are showing the same paths. Thanks for taking the time check out this thread. Any help will be greatly appreciated. MichaelQuote I have checked out %path% on the regular prompt and running it on the command file. They are showing the same paths. I was trying to find out of the system32 directory was on the path that the cmd file was using. The easiest solution would be to point the diskpart and shutdown commands to their home directory: Code in command file: Code: [Select]c:\windows\system32\diskpart.exe c:\windows\system32\shutdown.exe pause I SIMPLY copied your command file but be aware the pause statement will never get executed. The above code is only a workaround. Check out if the c:\windows\system32 directory is on the path by adding this code to your VBScript: Code: [Select]WScript.Echo "Path is " & Shell.ExpandEnvironmentStrings("%Path%") I got it fixed, I think. I am still not so sure why though. Here's what I was doing. command file 1 - execute a .vbs file using "call" on the .vbs file - calling command file 2 on command file 2 - contains "diskpart" and "shutdown" The two commands never got recognized. But after switched "call" to "cscript" using that to excute the .vbs file. It was working out just fine. Maybe there was something fishy about "call", I suppose. But anyway, thank you so much for reading this threat and the help, really appreciated! MICHAEL |
|