Hello I'm new here I need a script to check, if a folder exist and then run a file from the folder. If not, it should extract a ZIP file into a specific location. Thanks in advance!
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
'Objects
Set fso = CreateObject("Scripting.FileSystemObject")
Set shl = CreateObject("WScript.Shell")
path="C:\SomeFolderToExist\" 'path to folder
exists = fso.FolderExists(path)
if (exists) then
program="myprog.exe" 'Program name to run
shl.Run(path & program) 'Run a program
end if
For unzipping, I can only tell you to see this: Extract files from ZIP file with VBScript
回答2:
Replace shl.Run (C:\SYSTEM TOOLS\HWMonitor.exe)
with shl.Run (path & program)
. You do not need to specify the path and program there.
回答3:
If I understand correctly :
create a script: sudo vim script.sh
#!/bin/bash
echo "enter your path"
read path
if [[ -d "$path" ]]
then
echo $(sudo $path/yourprograme)
else
echo "enter your specific location"
read spec
$ mkdir -p $spec
$ unzip yourfiles.zip -d $spec
fi
run the scrip.sh : sudo ./script.sh