If you want the script in Windows Script Host 5.6 to run when you need to modify the current directory where the script is running, build an Wscript.Shell object, and then set the CurrentDirectory Value property to the directory you want. For example, the following two lines will change the current directory to C:\Temp
Set Objshell = CreateObject ("Wscript.Shell")
Objshell.currentdirectory = "C:\Temp"
To verify, copy this script and save it to another folder that is not C:\Temp and run, you can see two popup windows, one is the current folder, and the other is the new current folder C:\Temp
Set Objshell = CreateObject ("Wscript.Shell")
WScript.Echo Objshell.currentdirectory
Objshell.currentdirectory = "C:\Temp"
WScript.Echo Objshell.currentdirectory
Note that if the directory does not exist, there is an error: the object ' CurrentDirectory ' method ' IWshShell3 ' failed.
Welcome to scan or search for my "Windows Automation Operations" public number, and I will regularly publish the knowledge of Windows Automation operations on a daily basis for you to discuss.
650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M02/76/25/wKiom1ZLPSeCU-ZbAABsCkHlBCM246.jpg "title=" QRCode _for_gh_394ccb413d36_258.jpg "alt=" Wkiom1zlpsecu-zbaabsckhlbcm246.jpg "/>
This article from "Johnny" blog, declined reprint!
How to change the current directory where the script runs when the script runs